package com.gk.panda.apis.controller;

import com.alibaba.nacos.common.utils.HttpMethod;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gk.panda.apis.dto.EnvListDto;
import com.gk.panda.apis.entity.env.vo.EnvMonitorVO;
import com.gk.panda.apis.entity.env.vo.TrendVO;
import com.gk.panda.apis.log.Log;
import com.gk.panda.apis.service.DeviceEnvMonitorService;
import com.gk.panda.commons.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Description 生态环境监测
 * @Author zhangguoqiao
 * @Date 2022/12/14 02:16
 * @Version 1.0
 */
@RestController
@Api(tags = "生态环境监测接口")
@RequestMapping("/env/monitors")
public class DeviceEnvMonitorController {

    @Autowired
    private DeviceEnvMonitorService envMonitorService;

    @ApiOperation(value = "统计列表查询", httpMethod = HttpMethod.POST)
    @PostMapping("/list")
    public Result<IPage<EnvMonitorVO>> getEnvMonitorlList(@RequestBody EnvListDto dto) {
        return Result.ok(envMonitorService.getEnvMonitorlList(dto));
    }

    @GetMapping("/export")
    @Log
    @ApiOperation(value = "分页导出统计列表", httpMethod = HttpMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页数", required = true),
            @ApiImplicitParam(name = "pageSize", value = "大小", required = true)
    })
    public void exportEnvMonitor(HttpServletResponse response, @RequestParam("pageNumber") Integer pageNumber , @RequestParam("pageSize") Integer pageSize) {
        envMonitorService.exportEnvMonitor(response, pageNumber, pageSize);
    }

    @GetMapping("/trend")
    @ApiOperation(value = "获取过去24小时生态趋势图", httpMethod = HttpMethod.GET)
    @ApiImplicitParam(name = "orgId", required = true)
    public Result<List<TrendVO>> getTrendList(@RequestParam(value = "orgId") Integer orgId) {
        return Result.ok(envMonitorService.getTrendList(orgId));
    }

}
